package com.net.xpay.operator.controller.operator.common;

import com.net.common.model.ResultData;
import com.net.common.util.NetUtil;
import com.net.xpay.common.enums.user.ClientFrom;
import com.net.xpay.common.model.RegisterOperatorUserModel;
import com.net.xpay.common.service.OperatorUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author  on 28/01/2018.
 * 登录 http://127.0.0.1:9093/common/login/form?mobile=18812345678&loginMethod=password&clientFrom=pc_web&password=123456&rememberMe=true
 */
@Slf4j
@RestController
@RequestMapping("/common/register")
@Api(tags = "公共/用户注册", description = "公共 用户注册 net")
public class RegisterController {


    @Autowired
    private OperatorUserService operatorUserService;

    @ApiOperation(value = "注册")
    @PostMapping("/do-register")
    public ResultData<Boolean> doRegister(HttpServletRequest request, @RequestBody RegisterOperatorUserModel registerModel) {
        registerModel.setClientFrom(ClientFrom.WE_CHAT_MOBILE);
        registerModel.setIp(NetUtil.getRequestRealIp(request));
        operatorUserService.registerOperatorUser(registerModel);
        return new ResultData<>(true);
    }


}
